<template>
  <el-dialog
    v-model="visible"
    title="切换设备"
    width="900px"
    @close="closeDialog"
  >
    <el-table
      :data="state.equLsit"
      style="width: 100%"
      @row-dblclick="rowDoubleClick"
    >
      <el-table-column label="设备编码" prop="equipCode" width="120px" />
      <el-table-column label="设备名称" prop="equipName" />
      <el-table-column label="日期" prop="banciDate" width="120px" />
      <el-table-column label="班次" prop="banciName" width="80px" />
      <el-table-column label="是否模具" width="120px">
        <template #default="{ row }">
          <span>
            <el-icon v-if="row.useMold"><Check /></el-icon>
            <el-icon v-else><Minus /></el-icon>
          </span>
        </template>
      </el-table-column>
    </el-table>
  </el-dialog>
</template>
<script setup>
  import { Check, Minus } from '@element-plus/icons-vue'
  const state = reactive({
    equLsit: [],
    index: 0,
  })
  const visible = ref(false)
  const closeDialog = () => {
    visible.value = false
    state.equLsit = []
  }
  const handleOpen = (equList, index) => {
    state.equLsit = equList
    state.index = index
    visible.value = true
  }

  const rowDoubleClick = (row, a, b, c) => {
    console.log('rowDoubleClick', row, a, b, c)
    visible.value = false
    _emits('selectEquCallback', row)
  }
  defineExpose({
    handleOpen,
  })
  const _emits = defineEmits(['selectEquCallback'])
</script>
